package com.chongaizhen.sharding.code.service;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chongaizhen.sharding.code.mapper.UserMapper;
import com.chongaizhen.sharding.code.model.User;

import cn.hutool.core.lang.Snowflake;

/**
 * @author chongaizhen
 * @date 2021-07-15
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private Snowflake snowflake;

    public void insertUser() {
        User user = new User();
        user.setId(snowflake.nextId());
        System.out.println(user.getId());
        user.setTel(UUID.randomUUID().toString());
        userMapper.insertSelective(user);
    }

}
